package com.shuyuntu.proposal.entity;

import com.shuyuntu.proposal.enums.EArticleType;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by limeng on 16/8/22.
 */
@Entity
@Table(name = "article")
public class Article {
    /**
     * 提案的主键
     */
    private Integer id;

    /**
     * 提案的标题
     */
    private String title;

    /**
     * 提案的内容
     */
    private String content;

    /**
     * 提案的作者
     */
    private Delegate author;

    /**
     * 文章的类型
     */
    private EArticleType type;

    /**
     * 创建的时间
     */
    private Date createTime;

    /**
     * 修改的时间
     */
    private Date updateTime;

    /**
     * 发布的时间
     */
    private Date publishTime;

    /**
     * 点击次数
     */
    private int clickCount;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(nullable = false)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Column(nullable = false, length = 100000)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @ManyToOne
    @JoinColumn(name = "author_id", referencedColumnName = "id", nullable = false)
    public Delegate getAuthor() {
        return author;
    }

    public void setAuthor(Delegate author) {
        this.author = author;
    }

    @Temporal(TemporalType.TIME)
    @Column(nullable = false, name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time")
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "publish_time")
    public Date getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }

    @Column(columnDefinition = "int default 0", nullable = false, name = "click_count")
    public int getClickCount() {
        return clickCount;
    }

    public void setClickCount(int clickCount) {
        this.clickCount = clickCount;
    }

    @Column(nullable = false)
    @Enumerated(EnumType.ORDINAL)
    public EArticleType getType() {
        return type;
    }

    public void setType(EArticleType type) {
        this.type = type;
    }
}
